package net.jiupinshi.daoProvider;

import net.jiupinshi.entity.Store;
import net.jiupinshi.util.StringUtil;

/**
 * @Despription: 需要修改
 * @Author: penghui.guo
 * @Date: 2018/10/5 15:48
 */
public class StoreProvider {

    public String updateStoreById(Store store){
        StringBuilder sql = new StringBuilder("update store set");
        if(StringUtil.isNotEmpty(store.getUserName())){
            sql.append(" user_id = #{userId}, user_name = #{userName},");
        }
        if(StringUtil.isNotEmpty(store.getPhone())){
            sql.append(" phone = #{phone},");
        }
        if(StringUtil.isNotEmpty(store.getAddress())){
            sql.append(" address = #{address},");
        }
        if(StringUtil.isNotEmpty(store.getRemark())){
            sql.append(" remark = #{remark},");
        }
        if(store.getStatus() != null){
            sql.append(" status = #{status},");
        }
        sql.deleteCharAt(sql.length() -1);
        sql.append(" where id = #{id}");
        System.out.println(sql.toString());
        return sql.toString();
    }

    public String getStores(){
        StringBuilder sql = new StringBuilder("select id, name, user_name as userName from store where status = 1");
        return sql.toString();
    }
}
